home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / createMayaSoftwareCommonGlob < prev    next >
Encoding:
Text File  |  2003-07-17  |  60.6 KB  |  2,175 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. // ----------------------------------------------------------------------------
  18. // Utility procedures used by other procedures in this file
  19. //
  20.  
  21. proc setParentToCommonTab()
  22. {
  23.     setParent `rendererTabLayoutName("mayaSoftware")`;
  24.     setParent commonTabColumn;
  25. }
  26.  
  27. // ----------------------------------------------------------------------------
  28. // Code to create and update the file name preview area 
  29. //
  30.  
  31. proc createTargetFilePreview()
  32. {
  33.     string $oldParent = `setParent -query`;
  34.  
  35.     columnLayout 
  36.         -adjustableColumn true
  37.         targetFilePreview;
  38.  
  39.         text 
  40.             -align "left" 
  41.             -font "boldLabelFont" 
  42.             -label "Path" 
  43.             exampleText0;
  44.         text 
  45.             -align "left" 
  46.             -font "boldLabelFont" 
  47.             -label "File Name" 
  48.             exampleText1;
  49.         text 
  50.             -align "left" 
  51.             -font "boldLabelFont" 
  52.             -label "To" 
  53.             exampleText2;
  54.  
  55.     setParent $oldParent;
  56.  
  57.     // This target file preview is affected by a number of attributes.
  58.     // If any of those attributes change, this preview needs to be updated.
  59.     //
  60.     // Here we fill an array with the names of all of the current renderer's 
  61.     // attributes which affect the naming of the target file.
  62.     //
  63.     string $attrArray[];
  64.  
  65.     $attrArray[size($attrArray)] = "defaultRenderGlobals.imageFilePrefix";
  66.     $attrArray[size($attrArray)] = "defaultRenderGlobals.outFormatControl";
  67.     $attrArray[size($attrArray)] = "defaultRenderGlobals.imageFormat";
  68.     $attrArray[size($attrArray)] = "defaultRenderGlobals.outFormatExt";
  69.     $attrArray[size($attrArray)] = "defaultRenderGlobals.animation";
  70.     $attrArray[size($attrArray)] = "defaultRenderGlobals.imageFormat";
  71.     $attrArray[size($attrArray)] = "defaultRenderGlobals.byFrameStep";
  72.     $attrArray[size($attrArray)] = "defaultRenderGlobals.extensionPadding";
  73.     $attrArray[size($attrArray)] = "defaultRenderGlobals.startFrame";
  74.     $attrArray[size($attrArray)] = "defaultRenderGlobals.endFrame";
  75.     $attrArray[size($attrArray)] = "defaultRenderGlobals.modifyExtension";
  76.     $attrArray[size($attrArray)] = "defaultRenderGlobals.startExtension";
  77.     $attrArray[size($attrArray)] = "defaultRenderGlobals.byExtension";
  78.     $attrArray[size($attrArray)] = "defaultRenderGlobals.periodInExt";
  79.     $attrArray[size($attrArray)] = "defaultResolution.fields";
  80.     $attrArray[size($attrArray)] = "defaultRenderGlobals.fieldExtControl";
  81.     $attrArray[size($attrArray)] = "defaultRenderGlobals.oddFieldExt";
  82.     $attrArray[size($attrArray)] = "defaultRenderGlobals.evenFieldExt";
  83.     $attrArray[size($attrArray)] = "defaultRenderGlobals.putFrameBeforeExt";
  84.  
  85.     // Now we establish scriptJobs to invoke the procedure which updates the
  86.     // target file preview when any of the above attributes change.
  87.     //
  88.     int $i;
  89.  
  90.     for ($i = 0; $i < size($attrArray); $i++)
  91.     {
  92.         scriptJob
  93.             -attributeChange 
  94.                 $attrArray[$i]
  95.                 "updateMayaSoftwareTargetFilePreview"
  96.             -parent targetFilePreview;
  97.     }
  98.  
  99.     scriptJob 
  100.         -parent targetFilePreview
  101.         -event 
  102.             workspaceChanged 
  103.             "updateMayaSoftwareTargetFilePreview";
  104. }
  105.  
  106. global proc updateMayaSoftwareTargetFilePreview()
  107. {
  108.     //
  109.     // Description:
  110.     //    This procedure is called any time an attribute change occurs which 
  111.     //     would affect the name(s) of the file(s) that would be created when the
  112.     //     user performs a render.
  113.     //    This procedure updates the lines of text in the General tab that allow
  114.     //    the user to see what files are going to be created when they render.
  115.     //
  116.  
  117.     string $oldParent = `setParent -query`;
  118.  
  119.     string $renderer = "mayaSoftware";
  120.     string $tabLayout = rendererTabLayoutName($renderer);
  121.     setParent $tabLayout;
  122.  
  123.     //
  124.     // Update the Path portion of the preview.
  125.     //
  126.  
  127.     // get the project's image directory
  128.     //
  129.     string $imgDir = `workspace -q -rte "images"`;
  130.     string $fullPath = `workspace -expandName $imgDir`;
  131.  
  132.     $path = "  Path: "+ $fullPath + "/";
  133.         
  134.     text -edit -label $path exampleText0;
  135.  
  136.     //
  137.     // Update the File Name portion of the preview.
  138.     //
  139.  
  140.     string $title1 = "  File Name:  ";
  141.     string $title2 = "  To:             ";
  142.  
  143.     string $prefix = `getAttr defaultRenderGlobals.imageFilePrefix`;
  144.  
  145.     if ($prefix == "") 
  146.     {
  147.         $prefix = getSceneName(); 
  148.     }
  149.  
  150.     // Image extension
  151.     string $imageType;
  152.     int $imageUse = `getAttr "defaultRenderGlobals.outFormatControl"`;
  153.     if ($imageUse == 1)
  154.     {
  155.         // Don't use extension
  156.         $imageType = "";
  157.     } 
  158.     else if ($imageUse == 0) 
  159.     {
  160.         // Show the extension
  161.         global string $imgExt[];  // This is the actual file extension
  162.         global int $imgExtNum[];  // This is the corresponding internal value
  163.  
  164.         int $imageNum = `getAttr "defaultRenderGlobals.imageFormat"`;
  165.         for ($i=0; $i < size($imgExtNum); ++$i) 
  166.         {
  167.             if ($imageNum == $imgExtNum[$i]) 
  168.             {
  169.                 $imageType = $imgExt[$i];
  170.                 break;
  171.             }
  172.         }
  173.     } 
  174.     else if ($imageUse == 2) 
  175.     {
  176.         // User specified
  177.         $imageType = `getAttr "defaultRenderGlobals.outFormatExt"` ;
  178.     }
  179.     
  180.     // Frames number extension
  181.     string $frame1 = "";
  182.     string $frame2 = "";
  183.     int $useAnim = `getAttr "defaultRenderGlobals.animation"`;
  184.  
  185.     // If we have an animation file format, then we do not need frame number.
  186.     //
  187.     if ($useAnim)
  188.     {
  189.         if (multiframeFormat($imageType))
  190.         {
  191.             $useAnim = 0;
  192.         } 
  193.     }
  194.  
  195.     // Put the dot in front of the image type if the image type is not an
  196.     // empty string.
  197.     //
  198.     if ($imageType != "")
  199.     {
  200.         $imageType = "." + $imageType;
  201.     }
  202.  
  203.     if ($useAnim) 
  204.     {
  205.         // if useAnim, make sure it's not a movie format, or else
  206.         // bad extension names will be printed out to the window.
  207.         int $imgFormat = `getAttr "defaultRenderGlobals.imageFormat"`;
  208.         if ($imgFormat == 21 || $imgFormat == 22 || $imgFormat == 23)
  209.             $useAnim = 0;
  210.     }
  211.     if ($useAnim) 
  212.     {
  213.         float $byf = `getAttr defaultRenderGlobals.byFrameStep`;
  214.         if ($byf == 0.0) $byf = 0.00001;
  215.  
  216.         int $pad = `getAttr "defaultRenderGlobals.extensionPadding"`;
  217.         int $f1 = `getAttr "defaultRenderGlobals.startFrame"`;
  218.         int $f2 = `getAttr "defaultRenderGlobals.endFrame"`;
  219.         int $numFrames = ($f2 - $f1) / $byf;
  220.  
  221.         // Check to see if the numbers are being modified
  222.         if (`getAttr "defaultRenderGlobals.modifyExtension"`) 
  223.         {
  224.             $f1 = `getAttr defaultRenderGlobals.startExtension`;
  225.             $f2 = $f1 
  226.                 + ($numFrames * `getAttr defaultRenderGlobals.byExtension`);
  227.         }
  228.             
  229.         // Convert to strings
  230.         $frame1 = $f1;
  231.         $frame2 = $f2;
  232.  
  233.         // Pad the numbers
  234.         for ($i=size($frame1); $i<$pad; $i++) 
  235.         {
  236.             $frame1 = "0"+$frame1;
  237.         }
  238.         if (`getAttr "defaultRenderGlobals.periodInExt"`)
  239.         {
  240.             $frame1 = "."+$frame1;
  241.         }
  242.  
  243.         for ($i=size($frame2); $i<$pad; $i++) 
  244.         {
  245.             $frame2 = "0"+$frame2;
  246.         }
  247.         if (`getAttr "defaultRenderGlobals.periodInExt"`)
  248.         {
  249.             $frame2 = "."+$frame2;
  250.         }
  251.     }
  252.     
  253.     // Check for fields
  254.  
  255.     string $fieldExt = "";
  256.     int $whichFields = `getAttr defaultResolution.fields`;
  257.     int $useFields = ($whichFields != 0);
  258.     int $useFieldExt = (`getAttr "defaultRenderGlobals.fieldExtControl"` != 1);
  259.     int $defFieldExt = (`getAttr "defaultRenderGlobals.fieldExtControl"` == 0);
  260.     int $useCustom = (`getAttr "defaultRenderGlobals.fieldExtControl"` == 2);
  261.     
  262.     // Note that I am not using a "." in front of these.
  263.     // That's the way the code works now.  
  264.     // I think that there should be a "."
  265.     //
  266.     if ($useFields && $useFieldExt) 
  267.     {
  268.         // Add fields to the file name
  269.         if ($defFieldExt) 
  270.         {
  271.             if ($whichFields == 1) $fieldExt = "o";
  272.             if ($whichFields == 2) $fieldExt = "e";
  273.             if ($whichFields == 3 || $whichFields == 4) $fieldExt = "e (o)";
  274.         } 
  275.         else if ($useCustom) 
  276.         {
  277.             if ($whichFields == 1) 
  278.             {
  279.                 $fieldExt = `getAttr "defaultRenderGlobals.oddFieldExt"`;
  280.             }
  281.             if ($whichFields == 2) 
  282.             {
  283.                 $fieldExt = `getAttr "defaultRenderGlobals.evenFieldExt"`;
  284.             }
  285.             if ($whichFields == 3 || $whichFields == 4) 
  286.             {
  287.                 $fieldExt = `getAttr "defaultRenderGlobals.oddFieldExt"`
  288.                     + " (" 
  289.                     + `getAttr "defaultRenderGlobals.evenFieldExt"` 
  290.                     + ")";
  291.             }
  292.         }
  293.     }
  294.  
  295.     // Now put them all together to show what is going to happen
  296.  
  297.     int $frameBeforeExt = `getAttr "defaultRenderGlobals.putFrameBeforeExt"`;  
  298.     // 0=ext.frame, 1=frame.ext
  299.  
  300.     if ($frameBeforeExt == 0) 
  301.     {
  302.         text 
  303.             -edit 
  304.             -label ($title1+$prefix+$imageType+$frame1+$fieldExt) 
  305.             exampleText1;
  306.  
  307.         if ($useAnim) 
  308.         {
  309.             text 
  310.                 -edit 
  311.                 -label ($title2+$prefix+$imageType+$frame2+$fieldExt) 
  312.                 exampleText2;
  313.         } 
  314.         else 
  315.         {
  316.             text -edit -label "" exampleText2;
  317.         }
  318.     } 
  319.     else 
  320.     {
  321.         text 
  322.             -edit 
  323.             -label ($title1+$prefix+$frame1+$fieldExt+$imageType) 
  324.             exampleText1;
  325.  
  326.         if ($useAnim) 
  327.         {
  328.             text 
  329.                 -edit 
  330.                 -label ($title2+$prefix+$frame2+$fieldExt+$imageType) 
  331.                 exampleText2;
  332.         } 
  333.         else 
  334.         {
  335.             text -edit -label "" exampleText2;
  336.         }
  337.     }
  338.  
  339.     setParent $oldParent;
  340. }
  341.  
  342. // ----------------------------------------------------------------------------
  343. // Code to create and update the Image File Output frame 
  344. //
  345.  
  346. proc createFileNamePrefixControl()
  347. {
  348.     // Create the control
  349.     //
  350.     textFieldGrp 
  351.         -label "File Name Prefix" 
  352.         -changeCommand ("changeMayaSoftwareFileNamePrefix")
  353.         mayaSoftwareFileName;
  354.  
  355.     // Create a scriptJob which will update the control when the value of the
  356.     // attribute it represents is changed.
  357.     //
  358.     scriptJob
  359.         -parent mayaSoftwareFileName
  360.         -attributeChange 
  361.             "defaultRenderGlobals.imageFilePrefix"
  362.             "updateMayaSoftwareFileNamePrefixControl";
  363. }
  364.  
  365. global proc changeMayaSoftwareFileNamePrefix()
  366. {
  367.     setParentToCommonTab();
  368.  
  369.     string $prefix = `textFieldGrp -query -text mayaSoftwareFileName`;
  370.     string $prefixAttr = "defaultRenderGlobals.imageFilePrefix";
  371.  
  372.     if (    $prefix != "(not set; using filename)"
  373.         &&     isValidFileNamePrefix($prefix)) 
  374.     {
  375.         // The user has set the prefix to something, and it is a valid name, so
  376.         // we will set the value of the corresponding attribute.
  377.         //
  378.         setAttr $prefixAttr -type "string" $prefix;
  379.     }
  380.     else
  381.     {
  382.         // The user has set the prefix to an invalid value. We will refresh the
  383.         // UI to show the current value, which has not been changed.
  384.         //
  385.         updateMayaSoftwareFileNamePrefixControl();
  386.     }
  387. }
  388.  
  389. global proc updateMayaSoftwareFileNamePrefixControl()
  390. //
  391. //  Procedure Name:
  392. //      changeFileName
  393. //
  394. //  Description:
  395. //        This procedure is called when the user changes the file
  396. //        prefix.  It sets the internal representation of the prefix
  397. //        and then updates the example to show the changes.
  398. //
  399. {
  400.     string $oldParent = `setParent -query`;
  401.  
  402.     setParentToCommonTab();
  403.  
  404.     string $prefixAttr = "defaultRenderGlobals.imageFilePrefix";
  405.  
  406.     string $prefix = `getAttr $prefixAttr`;
  407.  
  408.     if (size($prefix) > 0) 
  409.     {
  410.         textFieldGrp -edit -text $prefix mayaSoftwareFileName;
  411.     } 
  412.     else 
  413.     {
  414.         textFieldGrp -edit -text "(not set; using filename)" mayaSoftwareFileName;
  415.     }
  416.  
  417.     setParent $oldParent;
  418. }
  419.  
  420. proc createFileNameFormatControl()
  421. {
  422.     optionMenuGrp 
  423.         -label "Frame/Animation Ext" 
  424.         -changeCommand ("changeMayaSoftwareFileNameFormat")
  425.         extMenu;
  426.  
  427.         menuItem -label "name (Single Frame)"; 
  428.         menuItem -label "name.ext (Single Frame)"; 
  429.         menuItem -label "name.#.ext" mayaSoftwareNameDotFrameDotExtension;
  430.         menuItem -label "name.ext.#" mayaSoftwareNameDotExtensionDotFrame;    
  431.         menuItem -label "name.#" mayaSoftwareNameDotFrame;    
  432.         menuItem -label "name#.ext" mayaSoftwareFrameDotExtension;    
  433.         menuItem -label "name (Multi Frame)" mayaSoftwareMultiFrame;    
  434.         menuItem -label "name.ext (Multi Frame)" 
  435.             mayaSoftwareMultiFrameDotExtension;    
  436.  
  437.     string $attrArray[];
  438.  
  439.     $attrArray[size($attrArray)] = "defaultRenderGlobals.outFormatControl";
  440.     $attrArray[size($attrArray)] = "defaultRenderGlobals.animation";
  441.     $attrArray[size($attrArray)] = "defaultRenderGlobals.periodInExt";
  442.     $attrArray[size($attrArray)] = "defaultRenderGlobals.putFrameBeforeExt";
  443.     $attrArray[size($attrArray)] = "defaultRenderGlobals.imageFormat";
  444.  
  445.     // Now we establish scriptJobs to invoke the procedure which updates the
  446.     // file name format control when any of the above attributes change.
  447.     //
  448.     int $i;
  449.  
  450.     for ($i = 0; $i < size($attrArray); $i++)
  451.     {
  452.         scriptJob
  453.             -attributeChange 
  454.                 $attrArray[$i]
  455.                 "updateMayaSoftwareFileNameFormatControl"
  456.             -parent extMenu;
  457.     }
  458. }
  459.  
  460. global proc changeMayaSoftwareFileNameFormat()
  461. //
  462. //  Procedure Name:
  463. //      changeExtension
  464. //
  465. //  Description:
  466. //        This procedure is called when the user changes the format
  467. //        of the file extension.  It sets the internal representation 
  468. //        and then updates the example to show the changes.
  469. //
  470. //    Note:
  471. //        Although the user sees only one control to change the
  472. //        extension, it actually affects more than one value.
  473. //
  474. {
  475.     setParentToCommonTab();
  476.  
  477.     global string $imgExt[];  // This is the actual file extension
  478.     global int $imgExtNum[];  // This is the corresponding internal value
  479.  
  480.     int $item = `optionMenuGrp -q -sl extMenu`;
  481.     int $imageFormatNum = `getAttr defaultRenderGlobals.imageFormat`;
  482.     int $multiframe = 
  483.         multiframeFormat(extOfImageFormat($imageFormatNum));
  484.     
  485.     // print ("changeExtension to " 
  486.     //     + $ext 
  487.     //    + " " 
  488.     //    + $imgExt[$ext] 
  489.     //    + "\nmultiframe " 
  490.     //    + $multiframe + "\n");
  491.  
  492.     if ($item == 1) // "name"
  493.     {
  494.         // Animation off
  495.         //
  496.         setAttr defaultRenderGlobals.animation 0;
  497.  
  498.         // No image file format type        
  499.         //
  500.         setAttr defaultRenderGlobals.outFormatControl 1;    
  501.         setAttr "defaultRenderGlobals.periodInExt" 1;
  502.     } 
  503.     else if ($item == 2) // "name.ext"
  504.     {
  505.         // Animation off
  506.         //
  507.         setAttr defaultRenderGlobals.animation 0;            
  508.  
  509.         if (`checkBoxGrp -q -v1 useCustomExtensionCtrl`) 
  510.         {
  511.             // Override image file format type
  512.             //
  513.             setAttr defaultRenderGlobals.outFormatControl 2;  
  514.         } 
  515.         else 
  516.         {
  517.             // Standard image file format type
  518.             //
  519.             setAttr defaultRenderGlobals.outFormatControl 0;    
  520.         }
  521.         setAttr "defaultRenderGlobals.periodInExt" 1;
  522.     }
  523.     else if ($item == 3) // "name.#.ext"
  524.     {
  525.         // Animation on
  526.         //
  527.         setAttr defaultRenderGlobals.animation 1; 
  528.  
  529.         if (`checkBoxGrp -q -v1 useCustomExtensionCtrl`)
  530.         {
  531.             // Override image file format type
  532.             //
  533.             setAttr defaultRenderGlobals.outFormatControl 2;  
  534.         }
  535.         else
  536.         {
  537.             // Standard image file format type
  538.             //
  539.             setAttr defaultRenderGlobals.outFormatControl 0;    
  540.         }
  541.         setAttr "defaultRenderGlobals.putFrameBeforeExt" 1;
  542.         setAttr "defaultRenderGlobals.periodInExt" 1;
  543.     }
  544.     else if ($item == 4) // "name.ext.#"
  545.     {
  546.         // Animation on
  547.         //
  548.         setAttr defaultRenderGlobals.animation 1;
  549.  
  550.         if (`checkBoxGrp -q -v1 useCustomExtensionCtrl`)
  551.         {
  552.             // Override image file format type
  553.             //
  554.             setAttr defaultRenderGlobals.outFormatControl 2;  
  555.         }
  556.         else
  557.         {
  558.             // Standard image file format type
  559.             //
  560.             setAttr defaultRenderGlobals.outFormatControl 0;    
  561.         }
  562.         setAttr "defaultRenderGlobals.putFrameBeforeExt" 0;
  563.         setAttr "defaultRenderGlobals.periodInExt" 1;
  564.     }
  565.     else if ($item == 5) // "name.#"
  566.     {
  567.         // Animation on
  568.         //
  569.         setAttr defaultRenderGlobals.animation 1;
  570.  
  571.         // No image file format type
  572.         //
  573.         setAttr defaultRenderGlobals.outFormatControl 1;
  574.         setAttr "defaultRenderGlobals.periodInExt" 1;
  575.     }
  576.     else if ($item == 6) // "name#.ext"
  577.     {
  578.         // Animation on
  579.         //
  580.         setAttr defaultRenderGlobals.animation 1;
  581.  
  582.         if (`checkBoxGrp -q -v1 useCustomExtensionCtrl`)
  583.         {
  584.             // Override image file format type
  585.             //
  586.             setAttr defaultRenderGlobals.outFormatControl 2;
  587.         }
  588.         else
  589.         {
  590.             // Standard image file format type
  591.             //
  592.             setAttr defaultRenderGlobals.outFormatControl 0;
  593.         }
  594.         setAttr "defaultRenderGlobals.putFrameBeforeExt" 1;
  595.         setAttr "defaultRenderGlobals.periodInExt" 0;
  596.     }
  597.     else if ($item == 7) // "name (Multi Frame)"
  598.     {
  599.         // Animation on
  600.         //
  601.         setAttr defaultRenderGlobals.animation 1;
  602.  
  603.         // No image file format type        
  604.         //
  605.         setAttr defaultRenderGlobals.outFormatControl 1;    
  606.         setAttr "defaultRenderGlobals.periodInExt" 1;
  607.     } 
  608.     else if ($item == 8) // "name.ext (Multi Frame)"
  609.     {
  610.         // Animation on 
  611.         //
  612.         setAttr defaultRenderGlobals.animation 1;            
  613.  
  614.         if (`checkBoxGrp -q -v1 useCustomExtensionCtrl`) 
  615.         {
  616.             // Override image file format type
  617.             //
  618.             setAttr defaultRenderGlobals.outFormatControl 2;  
  619.         } 
  620.         else 
  621.         {
  622.             // Standard image file format type
  623.             //
  624.             setAttr defaultRenderGlobals.outFormatControl 0;    
  625.         }
  626.         setAttr "defaultRenderGlobals.periodInExt" 1;
  627.     }
  628.  
  629.     // Update the batch render window if it exists
  630.     //
  631.     if (`exists updateBatchRenderWindowTitle`)
  632.     {
  633.         updateBatchRenderWindowTitle();
  634.     }
  635. }
  636.  
  637. global proc updateMayaSoftwareFileNameFormatControl()
  638. {
  639.     string $oldParent = `setParent -query`;
  640.  
  641.     setParentToCommonTab();
  642.  
  643.     int $frameBeforeExt    = `getAttr "defaultRenderGlobals.putFrameBeforeExt"`;
  644.     int $useAnim         = `getAttr "defaultRenderGlobals.animation"`;
  645.     int $imageUse         = `getAttr "defaultRenderGlobals.outFormatControl"`;
  646.     int $period         = `getAttr "defaultRenderGlobals.periodInExt"`;
  647.     int $imageFormatNum    = `getAttr "defaultRenderGlobals.imageFormat"`; 
  648.  
  649.     int $multiframe = 
  650.         multiframeFormat(extOfImageFormat($imageFormatNum));
  651.  
  652.     int $activeMenuItem = 0;
  653.  
  654.     // Update Frame/Animation Ext menuItems and enable only the relevant ones.
  655.     //
  656.     menuItem -edit -enable (!$multiframe) mayaSoftwareNameDotFrameDotExtension;
  657.     menuItem -edit -enable (!$multiframe) mayaSoftwareNameDotExtensionDotFrame;    
  658.     menuItem -edit -enable (!$multiframe) mayaSoftwareNameDotFrame;    
  659.     menuItem -edit -enable (!$multiframe) mayaSoftwareFrameDotExtension;    
  660.     menuItem -edit -enable $multiframe mayaSoftwareMultiFrame;    
  661.     menuItem -edit -enable $multiframe mayaSoftwareMultiFrameDotExtension;    
  662.  
  663.     if ($multiframe)
  664.     {
  665.         if ($useAnim)
  666.         {
  667.             if ($imageUse == 1)     // no extension
  668.             {
  669.                 $activeMenuItem = 7;
  670.             }
  671.             else
  672.             {
  673.                 $activeMenuItem = 8;
  674.             }
  675.         }
  676.         else
  677.         {
  678.             if ($imageUse == 1)     // no extension
  679.             {
  680.                 $activeMenuItem = 1;
  681.             }
  682.             else
  683.             {
  684.                 $activeMenuItem = 2;
  685.             }
  686.         }
  687.     }
  688.     else
  689.     {
  690.         if ($useAnim)
  691.         {
  692.                 if ($imageUse == 1)
  693.                 {
  694.                     $activeMenuItem = 5;
  695.                 }
  696.                 else
  697.             {
  698.                 if ($frameBeforeExt == 0)
  699.                 {
  700.                     $activeMenuItem = 4;
  701.                 } 
  702.                 else 
  703.                 {
  704.                     if ($period == 0)
  705.                     {
  706.                         $activeMenuItem = 6;
  707.                     }
  708.                     else
  709.                     {
  710.                         $activeMenuItem = 3;
  711.                     }
  712.                 }
  713.             }
  714.         } 
  715.         else 
  716.         {
  717.             if ($imageUse == 1)
  718.             {
  719.                 $activeMenuItem = 1;
  720.             } 
  721.             else 
  722.             {
  723.                 $activeMenuItem = 2;
  724.             }
  725.         }
  726.     }
  727.     
  728.     optionMenuGrp -edit -sl $activeMenuItem extMenu;
  729.  
  730.     // Also update the frame number controls to enable/disable them according
  731.     // to whether or not they are being used.
  732.     //
  733.     updateMayaSoftwareFrameNumberControls();
  734.  
  735.     setParent $oldParent;
  736. }
  737.  
  738. proc createUseCustomExtensionControl()
  739. {
  740.     checkBoxGrp 
  741.         -numberOfCheckBoxes 1
  742.         -label ""
  743.         -label1 "Use Custom Extension:" 
  744.         -changeCommand "changeMayaSoftwareUseCustomExtension"
  745.         useCustomExtensionCtrl;
  746.  
  747.     scriptJob 
  748.         -parent useCustomExtensionCtrl 
  749.         -attributeChange "defaultRenderGlobals.outFormatControl" 
  750.         "updateMayaSoftwareUseCustomExtensionControl";
  751. }
  752.  
  753. global proc updateMayaSoftwareUseCustomExtensionControl()
  754. {
  755.     string $oldParent = `setParent -query`;
  756.  
  757.     setParentToCommonTab();
  758.  
  759.     int $useImage = (`getAttr "defaultRenderGlobals.outFormatControl"` != 1);
  760.  
  761.     checkBoxGrp 
  762.         -edit 
  763.         -value1 (`getAttr "defaultRenderGlobals.outFormatControl"` == 2)
  764.         -enable $useImage
  765.         useCustomExtensionCtrl;
  766.  
  767.     setParent $oldParent;
  768. }
  769.  
  770. global proc changeMayaSoftwareUseCustomExtension()
  771. {
  772. // TODO: Update docs
  773. //
  774. //  Procedure Name:
  775. //      changeCustomExtensionCheck
  776. //
  777. //  Description:
  778. //        This procedure is called when the user turns the custom 
  779. //        extension on or off.  It sets the internal representation 
  780. //        and then updates the example to show the changes.
  781. //
  782.     setParentToCommonTab();
  783.  
  784.     int $isOn = `checkBoxGrp -query -value1 useCustomExtensionCtrl`;
  785.  
  786.     if ($isOn) 
  787.     {
  788.         setAttr defaultRenderGlobals.outFormatControl 2;
  789.     } 
  790.     else 
  791.     {
  792.         // We have to figure out if there should be an extension
  793.         // at all or not. 
  794.         //
  795.         int $item = `optionMenuGrp -query -select extMenu`;
  796.  
  797.         if ($item == 1 || $item == 5) 
  798.         {
  799.             setAttr defaultRenderGlobals.outFormatControl 1;
  800.         } 
  801.         else 
  802.         {
  803.             setAttr defaultRenderGlobals.outFormatControl 0;
  804.         }
  805.     }   
  806. }
  807.  
  808. proc createCustomExtensionControl()
  809. {
  810.     attrControlGrp
  811.         -label ""
  812.         -attribute defaultRenderGlobals.outFormatExt
  813.         userExt;
  814.  
  815.     scriptJob 
  816.         -parent userExt 
  817.         -attributeChange "defaultRenderGlobals.outFormatControl" 
  818.         "updateMayaSoftwareCustomExtensionControl";
  819. }
  820.  
  821. global proc updateMayaSoftwareCustomExtensionControl()
  822. {
  823.     string $oldParent = `setParent -query`;
  824.  
  825.     setParentToCommonTab();
  826.  
  827.     // TODO: Find a better name for value1
  828.     int $useImage = (`getAttr "defaultRenderGlobals.outFormatControl"` != 1);
  829.     int $value1 = (`getAttr "defaultRenderGlobals.outFormatControl"` == 2);
  830.     int $useExt = $useImage && $value1;
  831.  
  832.     attrControlGrp 
  833.         -edit
  834.         -enable $useExt
  835.         userExt;
  836.  
  837.     setParent $oldParent;
  838. }
  839.  
  840. proc createCompressorControlForMac(int $item)
  841. {
  842.         global string $imgExt[];
  843.         rowLayout -adjustableColumn true -nc 4 ;
  844.         text -l "";
  845.         button -l "Compression..." -width 80 -enable false -c "movieCompressor -softwareOptions" renderGlobalsCompression;
  846.         text -l "";
  847.         text -l "";
  848.         setParent ..;
  849.         if($imgExt[$item] == "qt"){
  850.             button -e -enable true renderGlobalsCompression;
  851.         }
  852.     
  853. }
  854.  
  855. proc enableMacCompressorbutton(int $item)
  856. {
  857.     global int  $imgExtNum[];
  858.     if(`about -mac`){
  859.         if($imgExtNum[$item] == 22){
  860.             button -e -enable true renderGlobalsCompression;
  861.         }else{
  862.             button -e -enable false renderGlobalsCompression;
  863.         }
  864.     }
  865. }
  866.  
  867.  
  868. proc createImageFormatControl()
  869. {
  870.     string $parent = `setParent -query`;
  871.  
  872.     // These tables translate between the internal representation of the
  873.     // image formats and the UI that is presented to the user.
  874.     //
  875.     // Fill up the below tables alphabetically.
  876.     // NOTE !!!! WARNING !!!! NOTE !!!! WARNING !!!! NOTE !!!! WARNING !!!!
  877.     // If you are changing one of the menuItem fields below or adding new ones 
  878.     // or whatever, be certain to also update the fields in the 
  879.     // 'createImageFormats()' procedure of createImageFormats.mel
  880.     // 
  881.     // TODO: There has got to be a better way of implementing this mechanism.
  882.  
  883.     optionMenuGrp 
  884.         -label "Image Format" 
  885.         -changeCommand "changeMayaSoftwareImageFormat"
  886.         imageMenu;
  887.  
  888.     if (`about -nt`) 
  889.     {
  890.         menuItem -label "Alias PIX (als)";      //  $imgExt[0]  = "als";  $imgExtNum[0]  = 6;
  891.         menuItem -label "AVI (avi)";            //  $imgExt[1]  = "avi";  $imgExtNum[1]  = 23;
  892.         menuItem -label "Cineon (cin)";         //  $imgExt[2]  = "cin";  $imgExtNum[2]  = 11;
  893.         menuItem -label "EPS (eps)";            //  $imgExt[3]  = "eps";  $imgExtNum[3]  = 9;
  894.         menuItem -label "GIF (gif)";            //  $imgExt[4]  = "gif";  $imgExtNum[4]  = 0;
  895.         menuItem -label "JPEG (jpeg)";          //  $imgExt[5]  = "jpeg"; $imgExtNum[5]  = 8;
  896.         menuItem -label "Maya IFF (iff)";       //  $imgExt[6]  = "iff";  $imgExtNum[6]  = 7;
  897.         menuItem -label "Maya16 IFF (iff)";     //  $imgExt[7]  = "iff";  $imgExtNum[7]  = 10;
  898.         menuItem -label "Quantel (yuv)";        //  $imgExt[8]  = "yuv";  $imgExtNum[8]  = 12;
  899.         menuItem -label "RLA (rla)";            //  $imgExt[9]  = "rla";  $imgExtNum[9]  = 2;
  900.         menuItem -label "SGI (sgi)";            //  $imgExt[10] = "sgi";  $imgExtNum[10]  = 5;
  901.         menuItem -label "SGI16 (sgi)";          //  $imgExt[11] = "sgi";  $imgExtNum[11] = 13;
  902.         menuItem -label "SoftImage (pic)";      //  $imgExt[12] = "pic";  $imgExtNum[12] = 1;
  903.         menuItem -label "Targa (tga)";          //  $imgExt[13] = "tga";  $imgExtNum[13] = 19;
  904.         menuItem -label "Tiff (tif)";           //  $imgExt[14] = "tif";  $imgExtNum[14] = 3;
  905.         menuItem -label "Tiff16 (tif)";         //  $imgExt[15] = "tif";  $imgExtNum[15] = 4;
  906.         menuItem -label "Windows Bitmap (bmp)"; //  $imgExt[16] = "bmp";  $imgExtNum[16] = 20;
  907.     } 
  908.     else if (`about -irix`)  
  909.     {
  910.         menuItem -label "Alias PIX (als)";        //  $imgExt[0]  = "als";  $imgExtNum[0]  = 6;
  911.         menuItem -label "AVI (avi)";            //  $imgExt[1]  = "avi";  $imgExtNum[1]  = 23;
  912.         menuItem -label "Cineon (cin)";            //  $imgExt[2]  = "cin";  $imgExtNum[2]  = 11;
  913.         menuItem -label "EPS (eps)";            //  $imgExt[3]  = "eps";  $imgExtNum[3]  = 9;
  914.         menuItem -label "GIF (gif)";            //  $imgExt[4]  = "gif";  $imgExtNum[4]  = 0;
  915.         menuItem -label "JPEG (jpeg)";            //  $imgExt[5]  = "jpeg"; $imgExtNum[5]  = 8;
  916.         menuItem -label "Maya IFF (iff)";          //  $imgExt[6]  = "iff";  $imgExtNum[6]  = 7;
  917.         menuItem -label "Maya16 IFF (iff)";        //  $imgExt[7]  = "iff";  $imgExtNum[7]  = 10;
  918.         menuItem -label "Quantel (yuv)";        //  $imgExt[8]  = "yuv";  $imgExtNum[8]  = 12;
  919.         menuItem -label "Quicktime (qt)";        //  $imgExt[9]  = "qt";   $imgExtNum[9]  = 22;
  920.         menuItem -label "RLA (rla)";            //  $imgExt[10]  = "rla"; $imgExtNum[10]  = 2;
  921.         menuItem -label "SGI (sgi)";            //  $imgExt[11] = "sgi";  $imgExtNum[11]  = 5;
  922.         menuItem -label "SGI16 (sgi)";            //  $imgExt[12] = "sgi";  $imgExtNum[12] = 13;
  923.         menuItem -label "SGI Movie (mv)";        //  $imgExt[13] = "mv";   $imgExtNum[13] = 21;
  924.         menuItem -label "SoftImage (pic)";        //  $imgExt[14] = "pic";  $imgExtNum[14] = 1;
  925.         menuItem -label "Targa (tga)";            //  $imgExt[15] = "tga";  $imgExtNum[15] = 19;
  926.         menuItem -label "Tiff (tif)";            //  $imgExt[16] = "tif";  $imgExtNum[16] = 3;
  927.         menuItem -label "Tiff16 (tif)";            //  $imgExt[17] = "tif";  $imgExtNum[17] = 4;
  928.         menuItem -label "Windows Bitmap (bmp)";    //  $imgExt[18] = "bmp";  $imgExtNum[18] = 20; 
  929.     } 
  930.     else if (`about -linux`)  
  931.     {
  932.         menuItem -label "Alias PIX (als)";        //  $imgExt[0]  = "als";  $imgExtNum[0]  = 6;
  933.         menuItem -label "Cineon (cin)";            //  $imgExt[1]  = "cin";  $imgExtNum[1]  = 11;
  934.         menuItem -label "EPS (eps)";            //  $imgExt[2]  = "eps";  $imgExtNum[2]  = 9;
  935.         menuItem -label "GIF (gif)";            //  $imgExt[3]  = "gif";  $imgExtNum[3]  = 0;
  936.         menuItem -label "JPEG (jpeg)";            //  $imgExt[4]  = "jpeg"; $imgExtNum[4]  = 8;
  937.         menuItem -label "Maya IFF (iff)";          //  $imgExt[5]  = "iff";  $imgExtNum[5]  = 7;
  938.         menuItem -label "Maya16 IFF (iff)";        //  $imgExt[6]  = "iff";  $imgExtNum[6]  = 10;
  939.         menuItem -label "Quantel (yuv)";        //  $imgExt[7]  = "yuv";  $imgExtNum[7]  = 12;
  940.         menuItem -label "RLA (rla)";            //  $imgExt[8]  = "rla";  $imgExtNum[8]  = 2;
  941.         menuItem -label "SGI (sgi)";            //  $imgExt[9] = "sgi";   $imgExtNum[9]  = 5;
  942.         menuItem -label "SGI16 (sgi)";            //  $imgExt[10] = "sgi";  $imgExtNum[10] = 13;
  943.         menuItem -label "SoftImage (pic)";        //  $imgExt[11] = "pic";  $imgExtNum[11] = 1;
  944.         menuItem -label "Targa (tga)";            //  $imgExt[12] = "tga";  $imgExtNum[12] = 19;
  945.         menuItem -label "Tiff (tif)";            //  $imgExt[13] = "tif";  $imgExtNum[13] = 3;
  946.         menuItem -label "Tiff16 (tif)";            //  $imgExt[14] = "tif";  $imgExtNum[14] = 4;
  947.         menuItem -label "Windows Bitmap (bmp)";    //  $imgExt[15] = "bmp";  $imgExtNum[15] = 20; 
  948.     } 
  949.     else if (`about -mac`) 
  950.     {
  951.         menuItem -label "JPEG (jpeg)";            //    $imgExt[0]  = "jpeg"; $imgExtNum[0]  = 8;
  952.         menuItem -label "Maya IFF (iff)";          //    $imgExt[1]  = "iff";  $imgExtNum[1]  = 7;
  953.         menuItem -label "Maya16 IFF (iff)";        //    $imgExt[2]  = "iff";  $imgExtNum[2]  = 10;
  954.         menuItem -label "MacPaint (pntg)";          //    $imgExt[3]  = "pntg"; $imgExtNum[3]  = 30;
  955.         menuItem -label "Photoshop (ps)";        //    $imgExt[4]  = "ps";      $imgExtNum[4]  = 31;
  956.         menuItem -label "PNG (png)";               //    $imgExt[5]  = "png";  $imgExtNum[5]  = 32;
  957.         menuItem -label "QuickDraw (pict)";        //    $imgExt[6]  = "pict"; $imgExtNum[6]  = 33;
  958.         menuItem -label "Quicktime Movie (qt)";    //    $imgExt[7]  = "qt";   $imgExtNum[7]  = 22;
  959.         menuItem -label "Quicktime Image (qtif)";//    $imgExt[8]  = "qtif"; $imgExtNum[8]  = 34;
  960.         menuItem -label "Silicon Graphics (sgi)";//    $imgExt[9] = "sgi";  $imgExtNum[9]  = 5;
  961.         menuItem -label "Targa (tga)";            //    $imgExt[10] = "tga";  $imgExtNum[10] = 19;
  962.         menuItem -label "Tiff (tif)";            //    $imgExt[11] = "tif";  $imgExtNum[11] = 3;
  963.         menuItem -label "Windows Bitmap (bmp)";    //    $imgExt[12] = "bmp";  $imgExtNum[12] = 20;
  964.     }
  965.     else 
  966.     {
  967.         warning "Unsupported platform in unifiedRenderGlobalsWindow.mel";
  968.     }
  969.  
  970.     scriptJob 
  971.         -parent $parent 
  972.         -attributeChange 
  973.             "defaultRenderGlobals.imageFormat" 
  974.             "updateMayaSoftwareImageFormatControl";
  975. }
  976.  
  977. global proc updateMayaSoftwareImageFormatControl()
  978. {
  979.     string $oldParent = `setParent -query`;
  980.  
  981.     global string $imgExt[];  // This is the actual file extension
  982.     global int $imgExtNum[];  // This is the corresponding internal value
  983.  
  984.     int $imageNum = `getAttr "defaultRenderGlobals.imageFormat"`;
  985.  
  986.     for ($i=0; $i < size($imgExtNum); ++$i) 
  987.     {
  988.         if ($imageNum == $imgExtNum[$i]) 
  989.         {
  990.             optionMenuGrp -edit -sl ($i+1) imageMenu;
  991.             enableMacCompressorbutton($i);
  992.             break;
  993.         }
  994.     }
  995.  
  996.     setParent $oldParent;
  997. }
  998.  
  999. global proc changeMayaSoftwareImageFormat()
  1000. {
  1001. //
  1002. //  Procedure Name:
  1003. //      changeImageFormat
  1004. //
  1005. //  Description:
  1006. //        This procedure is called when the user changes the type of 
  1007. //        image that will be written out.  It sets the internal 
  1008. //        representation and then updates the example to show the changes.
  1009. //
  1010.     setParentToCommonTab();
  1011.  
  1012.     global string $imgExt[];  // This is the actual file extension
  1013.     global int $imgExtNum[];  // This is the corresponding internal value
  1014.  
  1015.     int $item = `optionMenuGrp -q -sl imageMenu` - 1; 
  1016.     setAttr defaultRenderGlobals.imageFormat $imgExtNum[$item];
  1017.    
  1018.    enableMacCompressorbutton($item);
  1019.    
  1020.  
  1021.     // Check if the image format is IFF.
  1022.     //
  1023.     // Note: there are two IFF image types. One for 8 bit images
  1024.     // and one for 16 bit images. They both have an imgExt of iff.
  1025.  
  1026.     if ($imgExt[$item] != "iff") 
  1027.     {
  1028.         int $useBlur = `getAttr defaultRenderGlobals.motionBlur`;
  1029.         int $blur2d = (`getAttr defaultRenderGlobals.motionBlurType` == 0);
  1030.         int $keepMotionVector = (`getAttr defaultRenderGlobals.keepMotionVector` == 1);
  1031.         if ($useBlur && $blur2d && $keepMotionVector) 
  1032.         {
  1033.             warning
  1034.                 ("Non-IFF image formats are not supported when writing"+
  1035.                  " 2D motion vectors; setting image format to IFF");
  1036.  
  1037.             // Set globals imageFormat to Maya IFF
  1038.             setAttr defaultRenderGlobals.imageFormat 7;
  1039.         }
  1040.     }
  1041.  
  1042.     $item = `optionMenuGrp -q -sl imageMenu` - 1; 
  1043.     int $multiframe = multiframeFormat($imgExt[$item]);
  1044.  
  1045.     if ($multiframe)
  1046.     {
  1047.         setAttr defaultRenderGlobals.animation 1;
  1048.     }
  1049.  
  1050.     // Update the batch render window if it exists.    
  1051.     if (`exists updateBatchRenderWindowTitle`) 
  1052.     {
  1053.         updateBatchRenderWindowTitle();
  1054.     }
  1055. }
  1056.  
  1057. proc createCameraControl()
  1058. {
  1059.     //Note: not updating if changed elsewhere
  1060.     //
  1061.     optionMenuGrp 
  1062.         -label "Camera" 
  1063.         -changeCommand changeMayaSoftwareCamera 
  1064.         mayaSoftwareCameraMenu;
  1065. }
  1066.  
  1067. global proc updateMayaSoftwareCameraControl()
  1068. {
  1069.     string $oldParent = `setParent -query`;
  1070.  
  1071.     setParentToCommonTab();
  1072.  
  1073.     // This is a fix to get around the optionMenuGrp bug (#81337)
  1074.     string $fullName = `setParent "mayaSoftwareCameraMenu"`;
  1075.     string $menuName = ($fullName+"|OptionMenu");
  1076.     setParent -m $menuName;
  1077.  
  1078.     string $allCameras[] = `ls -cameras`;
  1079.     string $parents[];
  1080.     int    $i;
  1081.     int       $numRenderable = 0;
  1082.     string $cmd;
  1083.  
  1084.     //
  1085.     // First remove any existing menuItems; we're gonna rebuild the menu
  1086.     // from scratch each time.
  1087.  
  1088.     int $numOldMenuItems = `optionMenuGrp -q -ni mayaSoftwareCameraMenu`;
  1089.     string    $oldMenuItems[] = `optionMenuGrp -q -ill mayaSoftwareCameraMenu`;
  1090.  
  1091.     for ($i = 0; $i < $numOldMenuItems; $i++) 
  1092.     {
  1093.         deleteUI $oldMenuItems[$i];
  1094.     }
  1095.  
  1096.     // Run through the list of all of the cameras and build a
  1097.     // optionMenu of them that the user uses to select the
  1098.     // renderable camera.
  1099.     //
  1100.     // First count how many renderable cameras exist
  1101.     //
  1102.     for ($i = 0; $i < size($allCameras); $i++) 
  1103.     {
  1104.         if (`getAttr ($allCameras[$i] + ".renderable")`) 
  1105.         {
  1106.             $numRenderable++;
  1107.         }
  1108.     }
  1109.  
  1110.     int $firstRenderable = 0;
  1111.     for ($i = 0; $i < size($allCameras); $i++) 
  1112.     {
  1113.         $parents = `listRelatives -path -parent $allCameras[$i]`;
  1114.         string $menuItem = `menuItem -label $parents[0]`;
  1115.         // Use the first renderable camera
  1116.         if (`getAttr ($allCameras[$i] + ".renderable")`) 
  1117.         {
  1118.             $firstRenderable++;
  1119.             if ($firstRenderable == 1) 
  1120.             {
  1121.                 // Selected Camera -----------------------------------------
  1122.                 optionMenuGrp -edit -sl ($i+1) mayaSoftwareCameraMenu;
  1123.             }
  1124.             if ($numRenderable > 1) 
  1125.             {
  1126.                 string $camLabel = $parents[0] + " (Renderable)";
  1127.                 menuItem -edit -label $camLabel $menuItem;
  1128.             }
  1129.         }
  1130.     }
  1131.  
  1132.     setParent $oldParent;
  1133. }
  1134.  
  1135. global proc changeMayaSoftwareCamera()
  1136. {
  1137. //
  1138. //  Procedure Name:
  1139. //      changeMayaSoftwareCamera
  1140. //
  1141. //  Description:
  1142. //        This procedure is called when the user changes the camera
  1143. //        that will be rendered.
  1144. //        It updates the controls for the new camera
  1145. //
  1146.     setParentToCommonTab();
  1147.  
  1148.     //
  1149.     // First count how many renderable cameras exist
  1150.     //
  1151.     string $allCameras[] = `ls -cameras`;
  1152.  
  1153.     int $numRenderable = 0;
  1154.  
  1155.     for ($i = 0; $i < size($allCameras); $i++) 
  1156.     {
  1157.         if (`getAttr ($allCameras[$i] + ".renderable")`) 
  1158.         {
  1159.             $numRenderable++;
  1160.         }
  1161.     }
  1162.  
  1163.     int $camIndex = `optionMenuGrp -query -select mayaSoftwareCameraMenu` - 1;
  1164.  
  1165.     if ($numRenderable < 2) 
  1166.     {
  1167.         for ($i = 0; $i < size($allCameras); $i++) 
  1168.         {
  1169.             if ($i == $camIndex) 
  1170.             {
  1171.                 setAttr ($allCameras[$i] + ".renderable") 1;
  1172.             }
  1173.             else 
  1174.             {
  1175.                 setAttr ($allCameras[$i] + ".renderable") 0;
  1176.             }
  1177.         }
  1178.     }
  1179.  
  1180.     // Connect the channel controls to the new camera.
  1181.     //
  1182.     string $whichCamera = $allCameras[$camIndex];
  1183.     attrControlGrp -edit -attribute ($whichCamera + ".image") rgbChannel;
  1184.     attrControlGrp -edit -attribute ($whichCamera + ".mask") alphaChannel;
  1185.     attrControlGrp -edit -attribute ($whichCamera + ".depth") depthChannel;
  1186.  
  1187.     // Fix for 160069. The mental ray renderer and the Maya renderer
  1188.     // use the same renderable camera, so the mental ray render globals and
  1189.     // the Maya render globals must be kept in sync when the renderable camera
  1190.     // changes. The following code causes the attribute editor to be 
  1191.     // refreshed, just in case it contains the mental ray render globals.
  1192.     //
  1193.     global string $gAEFocusNode;
  1194.     updateAE($gAEFocusNode);
  1195. }
  1196.  
  1197. global proc updateMayaSoftwareFrameNumberControls()
  1198. {
  1199.     int $useAnim         = `getAttr "defaultRenderGlobals.animation"`;
  1200.     int $useCustomExt    = `getAttr "defaultRenderGlobals.modifyExtension"`;
  1201.     int $imageFormatNum    = `getAttr "defaultRenderGlobals.imageFormat"`; 
  1202.     int $multiframe = 
  1203.         multiframeFormat(extOfImageFormat($imageFormatNum));
  1204.  
  1205.     attrControlGrp 
  1206.         -edit
  1207.         -enable $useAnim
  1208.         startFrameCtrl;
  1209.     attrControlGrp 
  1210.         -edit
  1211.         -enable $useAnim
  1212.         endFrameCtrl;
  1213.     attrControlGrp 
  1214.         -edit
  1215.         -enable $useAnim
  1216.         byFrameStepCtrl;
  1217.     attrControlGrp 
  1218.         -edit
  1219.         -enable ($useAnim && !$multiframe)
  1220.         extensionPaddingCtrl;
  1221.     attrControlGrp
  1222.         -edit
  1223.         -enable ($useAnim && !$multiframe)
  1224.         modifyExtensionCtrl;
  1225.     attrControlGrp 
  1226.         -edit
  1227.         -enable ($useAnim && $useCustomExt && !$multiframe)
  1228.         startExtensionCtrl;
  1229.     attrControlGrp 
  1230.         -edit
  1231.         -enable ($useAnim && $useCustomExt && !$multiframe)
  1232.         byExtensionCtrl;
  1233. }
  1234.  
  1235. proc createCommonImageFile() 
  1236. //
  1237. //  Procedure Name:
  1238. //      createCommonImageFile
  1239. //
  1240. //  Description:
  1241. //      Creates the UI in the "Image File Output" expand/collapse section.
  1242. //        This section is always created so is treated differently
  1243. //        then the sections created when the tab is expanded.
  1244. //
  1245. {
  1246.     string $parent = `setParent -query`;
  1247.  
  1248.     setUITemplate -pushTemplate attributeEditorTemplate;
  1249.  
  1250.     global string $imgExt[];
  1251.  
  1252.     if (size($imgExt) == 0)
  1253.     {
  1254.         // If the file format array has not been initialized yet, do so.
  1255.         // This routine may be called in dynPaintMenus.mel during the
  1256.         // file save for PFX canvas images.
  1257.         //
  1258.         createImageFormats();
  1259.     }
  1260.     
  1261.     columnLayout -adjustableColumn true;
  1262.  
  1263.         createFileNamePrefixControl();
  1264.         createFileNameFormatControl();
  1265.         createImageFormatControl();
  1266.         if(`about -mac`){
  1267.             int $item = `optionMenuGrp -q -sl imageMenu` - 1; 
  1268.             createCompressorControlForMac($item);
  1269.         }
  1270.  
  1271.         separator;
  1272.     
  1273.         // Frame numbers ------------------------------------------------
  1274.  
  1275.         attrControlGrp 
  1276.             -attribute defaultRenderGlobals.startFrame 
  1277.             -label "Start Frame"
  1278.             -hideMapButton true
  1279.             startFrameCtrl;
  1280.         attrControlGrp 
  1281.             -attribute defaultRenderGlobals.endFrame 
  1282.             -label "End Frame"
  1283.             -hideMapButton true
  1284.             endFrameCtrl;
  1285.         attrControlGrp 
  1286.             -attribute defaultRenderGlobals.byFrameStep
  1287.             -label "By Frame"
  1288.             -hideMapButton true
  1289.             byFrameStepCtrl;
  1290.         attrControlGrp 
  1291.             -attribute defaultRenderGlobals.extensionPadding
  1292.             -label "Frame Padding"
  1293.             -hideMapButton true
  1294.             extensionPaddingCtrl;
  1295.  
  1296.         separator;
  1297.  
  1298.         // Renderable Objects ------------------------------------------------
  1299.  
  1300.         attrEnumOptionMenuGrp
  1301.             -label "Renderable Objects" 
  1302.             -attribute "defaultRenderGlobals.renderAll"
  1303.             -enumeratedItem 1 "Render All"
  1304.             -enumeratedItem 0 "Render Active";
  1305.  
  1306.         // Cameras ------------------------------------------------
  1307.  
  1308.         createCameraControl();
  1309.         updateMayaSoftwareCameraControl();
  1310.  
  1311.         // Channels ------------------------------------------------
  1312.  
  1313.         //
  1314.         string $currentCamera = `optionMenuGrp -q -v mayaSoftwareCameraMenu`;
  1315.         //
  1316.         // Remove the substring " (Renderable)" from the string
  1317.         // $currentCamera if there is any.
  1318.         //
  1319.         $currentCamera = `substitute " .*" $currentCamera ""`;
  1320.         string $camShapes[] = `listRelatives -path -shapes $currentCamera`;
  1321.         $currentCamera = $camShapes[0];
  1322.  
  1323.         attrControlGrp
  1324.             -label "RGB Channel (Color)"
  1325.             -attribute ($currentCamera + ".image")
  1326.             rgbChannel;
  1327.         attrControlGrp
  1328.             -label "Alpha Channel (Mask)"
  1329.             -attribute ($currentCamera + ".mask")
  1330.             alphaChannel;
  1331.         attrControlGrp
  1332.             -label "Depth Channel (Z Depth)"
  1333.             -attribute ($currentCamera + ".depth")
  1334.             depthChannel;
  1335.  
  1336.         // Custom Extension ----------------------------------------
  1337.  
  1338.         frameLayout
  1339.             -label "Custom Extension"
  1340.             -collapsable true
  1341.             -collapse true;
  1342.  
  1343.             columnLayout;
  1344.  
  1345.                 createUseCustomExtensionControl();
  1346.                 createCustomExtensionControl();
  1347.  
  1348.             setParent ..;
  1349.         setParent ..;
  1350.  
  1351.         // Renumber ------------------------------------------------
  1352.         
  1353.         frameLayout
  1354.             -label "Renumber Frames"
  1355.             -collapsable true
  1356.             -collapse true;
  1357.  
  1358.             columnLayout;
  1359.  
  1360.                 attrControlGrp 
  1361.                     -attribute defaultRenderGlobals.modifyExtension
  1362.                     -changeCommand "updateMayaSoftwareFrameNumberControls"
  1363.                     -label "Renumber Frames Using:"
  1364.                     modifyExtensionCtrl;
  1365.                 attrControlGrp 
  1366.                     -attribute defaultRenderGlobals.startExtension
  1367.                     -enable (`getAttr defaultRenderGlobals.modifyExtension`)
  1368.                     -hideMapButton true
  1369.                     -label "Start Number"
  1370.                     startExtensionCtrl;
  1371.                 attrControlGrp 
  1372.                     -attribute defaultRenderGlobals.byExtension
  1373.                     -enable (`getAttr defaultRenderGlobals.modifyExtension`)
  1374.                     -hideMapButton true
  1375.                     -label "By Frame"
  1376.                     byExtensionCtrl;
  1377.  
  1378.             setParent ..;
  1379.         setParent ..;
  1380.  
  1381.     setParent $parent;
  1382.     setUITemplate -popTemplate;
  1383.  
  1384.     // Perform an initial update of the UI created above, so that controls
  1385.     // which are not directly connected to attributes are properly initialized.
  1386.     //
  1387.     updateMayaSoftwareFileNamePrefixControl();
  1388.     updateMayaSoftwareFileNameFormatControl();
  1389.     updateMayaSoftwareImageFormatControl();
  1390.     updateMayaSoftwareUseCustomExtensionControl();
  1391.     updateMayaSoftwareCustomExtensionControl();
  1392. }
  1393.  
  1394. // ----------------------------------------------------------------------------
  1395. // Code to create and update the Resolution frame 
  1396. //
  1397.  
  1398. global proc createCommonResolution()
  1399. //
  1400. //  Procedure Name:
  1401. //      createCommonResolution
  1402. //
  1403. //  Description:
  1404. //      Creates the UI in the "Resolution" expand/collapse section.
  1405. //
  1406. {
  1407.     //
  1408.     // Make sure the list of predefined resolutions has been read in.
  1409.     //
  1410.     global string   $gImageFormatData[];
  1411.     global string   $gUserImageFormatData[];
  1412.  
  1413.     if (size($gImageFormatData) == 0) 
  1414.     {
  1415.         eval("source imageFormats");
  1416.     }
  1417.  
  1418.     int $isMayaEvalVersion = `about -ev`;
  1419.     global string   $gPLEImageFormatData[];
  1420.     if ($isMayaEvalVersion) 
  1421.     {
  1422.         $gImageFormatData = $gPLEImageFormatData;
  1423.     }
  1424.  
  1425.     if (exists("userImageFormats.mel") && size($gUserImageFormatData) == 0) 
  1426.     {
  1427.         // Yes, we need the eval here, to avoid doing the source
  1428.         // until we know whether the file actually exists
  1429.         eval("source userImageFormats");
  1430.     }
  1431.  
  1432.     setUITemplate -pushTemplate attributeEditorTemplate;
  1433.  
  1434.     // If the UI is created already then just update the attribute values.
  1435.     if (`columnLayout -exists rgResolutionLayout`) 
  1436.     {
  1437.         updateMayaSoftwareResolution();
  1438.         return;
  1439.     }
  1440.  
  1441.     columnLayout -adjustableColumn true rgResolutionLayout;
  1442.         int        $resItem;
  1443.         int        $numResolutionPresets = size($gImageFormatData);
  1444.         int        $numUserResolutionPresets = size($gUserImageFormatData);
  1445.         string  $allResNodes[] = `ls -type resolution`;
  1446.         int        $numResolutionNodePresets = size($allResNodes) - 1;
  1447.         int        $numTokens;
  1448.         string    $tokens[];
  1449.         string  $niceName;
  1450.  
  1451.         optionMenuGrp 
  1452.             -label "Presets" 
  1453.             -changeCommand "changeMayaSoftwareResolution()" 
  1454.             resolutionMenu;
  1455.  
  1456.             menuItem -label "Custom";
  1457.             for ($resItem = 0; $resItem < $numResolutionPresets; $resItem++) 
  1458.             {
  1459.                 string $item = $gImageFormatData[$resItem];
  1460.                 $numTokens = tokenize($item, $tokens);
  1461.  
  1462.                 // Change any underscore into a space;
  1463.                 // some names may have up to 2 underscores in them,
  1464.                 // so we do this twice.
  1465.                 //
  1466.                 $niceName = `substitute "_" $tokens[0] " "`;
  1467.                 $niceName = `substitute "_" $niceName " "`;
  1468.                 menuItem -label $niceName;
  1469.             }
  1470.             for ($resItem = 0; $resItem < $numUserResolutionPresets; $resItem++)
  1471.             {
  1472.                 string $item = $gUserImageFormatData[$resItem];
  1473.                 $numTokens = tokenize($item, $tokens);
  1474.  
  1475.                 // Change any underscore into a space;
  1476.                 // some names may have up to 2 underscores in them,
  1477.                 // so we do this twice.
  1478.                 //
  1479.                 $niceName = `substitute "_" $tokens[0] " "`;
  1480.                 $niceName = `substitute "_" $niceName " "`;
  1481.                 menuItem -label $niceName;
  1482.             }
  1483.             for ($resItem = 0; $resItem < $numResolutionNodePresets; $resItem++)
  1484.             {
  1485.                 menuItem -label $allResNodes[$resItem + 1];
  1486.             }
  1487.  
  1488.         separator;
  1489.         
  1490.         checkBoxGrp -numberOfCheckBoxes 1
  1491.             -label1 "Maintain Width/Height Ratio"
  1492.             -changeCommand 
  1493.                 ("setAttr defaultResolution.aspectLock #1;"
  1494.                     + "checkMayaSoftwareAspectLock \"defaultResolution\";"
  1495.                     + "updateMayaSoftwareResolution")
  1496.             aspectLockCheck;
  1497.  
  1498.         intFieldGrp -label "Width" 
  1499.             -changeCommand "changeMayaSoftwareAspectLockWidth"
  1500.             mayaSoftwareResWidth;
  1501.         intFieldGrp -label "Height" 
  1502.             -changeCommand "changeMayaSoftwareAspectLockHeight"
  1503.             mayaSoftwareResHeight;
  1504.         
  1505.         separator;
  1506.  
  1507.         checkBoxGrp -numberOfCheckBoxes 1
  1508.             -label1 "Lock Device Aspect Ratio" 
  1509.             -changeCommand 
  1510.                 ("setAttr defaultResolution.lockDeviceAspectRatio #1;"
  1511.                     + "changeMayaSoftwareAspectLockWidth")
  1512.             ratioLockCheck;
  1513.  
  1514.         floatFieldGrp -label "Device Aspect Ratio"  
  1515.             -changeCommand "updateMayaSoftwareDeviceAspectRatio"
  1516.             resRatio;
  1517.  
  1518.         floatFieldGrp -label "Pixel Aspect Ratio"  
  1519.             -changeCommand "adjustMayaSoftwareDeviceAspect \"defaultResolution\"" 
  1520.             pixRatio;
  1521.  
  1522.     setParent ..;
  1523.     setUITemplate -popTemplate;
  1524.  
  1525.     // Make sure the values are right
  1526.     updateMayaSoftwareResolution();
  1527. }
  1528.  
  1529. global proc updateMayaSoftwareResolution()
  1530. //
  1531. //  Procedure Name:
  1532. //      updateResolution
  1533. //
  1534. //  Description:
  1535. //      Gets the real values from the nodes and sets the UI based
  1536. //        on these values.  This procedure updates all of the resolution
  1537. //        values.
  1538. //
  1539. {
  1540.     setParentToCommonTab();
  1541.  
  1542.     int $width = `getAttr defaultResolution.width`;
  1543.     int $height = `getAttr defaultResolution.height`;
  1544.     float $aspect = `getAttr defaultResolution.deviceAspectRatio`;
  1545.     int $resItem;
  1546.     int $whichRes = 1; // use "Custom" if no match is found
  1547.     string $allResNodes[] = `ls -type resolution`;
  1548.  
  1549.     global string   $gImageFormatData[];
  1550.     global string   $gUserImageFormatData[];
  1551.     int        $numResolutionPresets = size($gImageFormatData);
  1552.     int        $numUserResolutionPresets = size($gUserImageFormatData);
  1553.     int        $numResolutionNodePresets = size($allResNodes) - 1;
  1554.     int        $resWidth;
  1555.     int        $resHeight;
  1556.     float    $resAspect;
  1557.     int        $numTokens;
  1558.     string    $tokens[];
  1559.  
  1560.     for ($resItem = 0; $resItem < $numResolutionPresets; $resItem++) 
  1561.     {
  1562.         string $item = $gImageFormatData[$resItem];
  1563.         $numTokens = tokenize($item, $tokens);
  1564.         if ($numTokens == 4) 
  1565.         {
  1566.             $resWidth = $tokens[1];
  1567.             $resHeight = $tokens[2];
  1568.             $resAspect = $tokens[3];
  1569.             if ($width == $resWidth && $height == $resHeight
  1570.                     && abs($aspect - $resAspect) < 0.001) 
  1571.             {
  1572.                 // We add _2_ to $resItem below: 1 because we're
  1573.                 // skipping the first item (Custom) in the list, and 1
  1574.                 // because the optionMenu items are numbered starting at 1,
  1575.                 // but our list in $gImageFormatData is indexed starting at 0.
  1576.                 $whichRes = $resItem + 2;
  1577.                 break;
  1578.             }
  1579.         } 
  1580.         else 
  1581.         {
  1582.             warning(
  1583.                 "Found invalid image format description: \""
  1584.                 + $item 
  1585.                 + "\" in imageFormats.mel");
  1586.         }
  1587.     }
  1588.  
  1589.     // If no match was found in the built-in resolutions,
  1590.     // check out the user-defined ones
  1591.     //
  1592.     if ($whichRes == 1) 
  1593.     {
  1594.         for ($resItem = 0; $resItem < $numUserResolutionPresets; $resItem++) 
  1595.         {
  1596.             string $item = $gUserImageFormatData[$resItem];
  1597.             $numTokens = tokenize($item, $tokens);
  1598.             if ($numTokens == 4) 
  1599.             {
  1600.                 $resWidth = $tokens[1];
  1601.                 $resHeight = $tokens[2];
  1602.                 $resAspect = $tokens[3];
  1603.                 if ($width == $resWidth && $height == $resHeight
  1604.                         && abs($aspect - $resAspect) < 0.001) 
  1605.                 {
  1606.                     $whichRes = $numResolutionPresets + $resItem + 2;
  1607.                     break;
  1608.                 }
  1609.             } 
  1610.             else 
  1611.             {
  1612.                 warning(
  1613.                     "Found invalid image format description: \""
  1614.                     + $item 
  1615.                     + "\" in userImageFormats.mel");
  1616.             }
  1617.         }
  1618.     }
  1619.  
  1620.     // If no match was found in the user-defined resolutions,
  1621.     // see if there are any 'extra' resolution nodes in the scene.
  1622.     //
  1623.     if ($whichRes == 1) 
  1624.     {
  1625.         for ($resItem = 0; $resItem < $numResolutionNodePresets; $resItem++) 
  1626.         {
  1627.             // We assume the 0th item in the list of resolution nodes is
  1628.             // the default one, which is created implicitly...
  1629.             //
  1630.             string $resNodeName = $allResNodes[$resItem + 1];
  1631.  
  1632.             $resWidth = `getAttr ($resNodeName + ".width")`;
  1633.             $resHeight = `getAttr ($resNodeName + ".height")`;
  1634.             $resAspect = `getAttr ($resNodeName + ".deviceAspectRatio")`;
  1635.  
  1636.             if ($width == $resWidth && $height == $resHeight
  1637.                     && abs($aspect - $resAspect) < 0.001) 
  1638.             {
  1639.                 // We add _2_ to $resItem below: 1 because we're
  1640.                 // skipping the first item (Custom) in the list, and 1
  1641.                 // because the optionMenu items are numbered starting at 1,
  1642.                 // but our list in $gImageFormatData is indexed starting at 0.
  1643.                 //
  1644.                 $whichRes = $numResolutionPresets
  1645.                             + $numUserResolutionPresets + $resItem + 2;
  1646.                 break;
  1647.             }
  1648.         }
  1649.     }
  1650.     optionMenuGrp -edit -sl $whichRes resolutionMenu;
  1651.  
  1652.     checkBoxGrp -edit -v1 `getAttr defaultResolution.aspectLock` aspectLockCheck;
  1653.     intFieldGrp -edit -v1 $width mayaSoftwareResWidth;
  1654.     intFieldGrp -edit -v1 $height mayaSoftwareResHeight;
  1655.     floatFieldGrp -edit -v1 $aspect resRatio;
  1656.     adjustMayaSoftwarePixelAspect "defaultResolution";
  1657.     checkBoxGrp -edit -v1 `getAttr defaultResolution.lockDeviceAspectRatio` ratioLockCheck;
  1658. }
  1659.  
  1660. global proc changeMayaSoftwareResolution()
  1661. //
  1662. //  Procedure Name:
  1663. //      changeResolution
  1664. //
  1665. //  Description:
  1666. //        This procedure is called when the user selects a different
  1667. //        resolution.  It sets the internal representation
  1668. //        and then updates the example to show the changes.
  1669. //
  1670. {
  1671.     setParentToCommonTab();
  1672.  
  1673.     global string   $gImageFormatData[];
  1674.     global string   $gUserImageFormatData[];
  1675.     int        $numResolutionPresets = size($gImageFormatData);
  1676.     int        $numUserResolutionPresets = size($gUserImageFormatData);
  1677.     string $allResNodes[] = `ls -type resolution`;
  1678.     int        $numResolutionNodePresets = size($allResNodes) - 1;
  1679.     string    $tokens[];
  1680.     int        $resItem = `optionMenuGrp -q -sl resolutionMenu`; 
  1681.     int        $resWidth;
  1682.     int        $resHeight;
  1683.     float    $resAspect;
  1684.     string    $item;
  1685.  
  1686.     // Item #1 is Custom, which doesn't change the fields
  1687.     // We subtract _2_ from $resItem below: 1 because we're
  1688.     // skipping the first item (Custom) in the list, and 1
  1689.     // because the optionMenu items are numbered starting at 1,
  1690.     // but our list in $gImageFormatData is indexed starting at 0.
  1691.     //
  1692.     if ($resItem > 1) 
  1693.     {
  1694.         if ($resItem > ($numResolutionPresets + 1)) 
  1695.         {
  1696.             if ($resItem
  1697.                     > ($numResolutionPresets + $numUserResolutionPresets + 1)) 
  1698.             {
  1699.                 // It's one of the user-defined resolution nodes' presets
  1700.                 string $resNodeName = $allResNodes[$resItem
  1701.                                                 - $numResolutionPresets
  1702.                                                 - $numUserResolutionPresets
  1703.                                                 - 1];
  1704.                 $resWidth = `getAttr ($resNodeName + ".width")`;
  1705.                 $resHeight = `getAttr ($resNodeName + ".height")`;
  1706.                 $resAspect = `getAttr ($resNodeName + ".deviceAspectRatio")`;
  1707.             } 
  1708.             else 
  1709.             {
  1710.                 // It's one of the user-defined resolution presets
  1711.                 $item = $gUserImageFormatData[$resItem
  1712.                     - $numResolutionPresets - 2];
  1713.                 int        $numTokens = tokenize($item, $tokens);
  1714.                 $resWidth = $tokens[1];
  1715.                 $resHeight = $tokens[2];
  1716.                 $resAspect = $tokens[3];
  1717.             }
  1718.         } 
  1719.         else 
  1720.         {
  1721.             // It's one of the built-in resolution presets
  1722.             $item = $gImageFormatData[$resItem - 2];
  1723.             int        $numTokens = tokenize($item, $tokens);
  1724.             $resWidth = $tokens[1];
  1725.             $resHeight = $tokens[2];
  1726.             $resAspect = $tokens[3];
  1727.         }
  1728.         setAttr "defaultResolution.width" $resWidth;
  1729.         setAttr "defaultResolution.height" $resHeight;
  1730.         setAttr "defaultResolution.deviceAspectRatio" $resAspect;
  1731.         setAttr "defaultResolution.lockDeviceAspectRatio" 1;
  1732.  
  1733.         // Set the proper field ordering if PAL or NTSC.
  1734.         if (`getAttr defaultResolution.height` == 576) // PAL
  1735.         {
  1736.             setAttr "defaultResolution.oddFieldFirst" 0;
  1737.             if (`columnLayout -exists rgFieldLayout`) 
  1738.             {
  1739.                 if (`exists updateFieldOptions`)
  1740.                 {
  1741.                     updateFieldOptions();
  1742.                 }
  1743.             }
  1744.         } 
  1745.         else if (`getAttr defaultResolution.height` == 486) // NTSC
  1746.         {
  1747.             setAttr "defaultResolution.oddFieldFirst" 1;
  1748.             if (`columnLayout -exists rgFieldLayout`) 
  1749.             {
  1750.                 if (`exists updateFieldOptions`)
  1751.                 {
  1752.                     updateFieldOptions();
  1753.                 }
  1754.             }
  1755.         }
  1756.     }
  1757.  
  1758.     updateMayaSoftwareResolution();
  1759. }
  1760.  
  1761. global proc checkMayaSoftwareAspectLockWidth(string $nodeName)
  1762. {
  1763.     float $deviceAspect;
  1764.  
  1765.     if (`getAttr ($nodeName + ".aspectLock")`) 
  1766.     {
  1767.         int $value = `getAttr ($nodeName + ".width")`;
  1768.     
  1769.         float $aspect = `getAttr ($nodeName + ".pixelAspect")`;
  1770.     
  1771.         if ($aspect > 0.0)
  1772.         {
  1773.             int $rez = $aspect * $value;
  1774.             int $oldrez = `getAttr ($nodeName + ".height")`;
  1775.             if ($rez - $oldrez > 1 || $oldrez - $rez > 1) 
  1776.             {
  1777.                 setAttr ($nodeName + ".height") $rez;
  1778.             }
  1779.         } 
  1780.         else 
  1781.         {
  1782.             checkMayaSoftwareAspectLock $nodeName;
  1783.         }
  1784.     }
  1785.  
  1786.     if (`getAttr ($nodeName + ".lockDeviceAspectRatio")` == 0) 
  1787.     {
  1788.         $deviceAspect = `getAttr ($nodeName + ".width")`;
  1789.         $deviceAspect = $deviceAspect / `getAttr ($nodeName + ".height")`;
  1790.         setAttr ($nodeName + ".deviceAspectRatio") $deviceAspect;
  1791.     }
  1792. }
  1793.  
  1794. global proc checkMayaSoftwareAspectLockHeight(string $nodeName)
  1795. {
  1796.     float $deviceAspect;
  1797.  
  1798.     if (`getAttr ($nodeName + ".aspectLock")`)
  1799.     {
  1800.         int $value = `getAttr ($nodeName + ".height")`;
  1801.         
  1802.         float $aspect = `getAttr ($nodeName + ".pixelAspect")`;
  1803.     
  1804.         if ($aspect > 0.0)
  1805.         {
  1806.             int $rez = $value / $aspect;
  1807.             int $oldrez = `getAttr ($nodeName + ".width")`;
  1808.             if ($rez - $oldrez > 1 || $oldrez - $rez > 1)
  1809.             {
  1810.                 setAttr ($nodeName + ".width") $rez;
  1811.             }
  1812.         }
  1813.         else
  1814.         {
  1815.             checkMayaSoftwareAspectLock $nodeName;
  1816.         }
  1817.     }
  1818.  
  1819.     if (`getAttr ($nodeName + ".lockDeviceAspectRatio")` == 0)
  1820.     {
  1821.         $deviceAspect = `getAttr ($nodeName + ".width")`;
  1822.         $deviceAspect = $deviceAspect / `getAttr ($nodeName + ".height")`;
  1823.         setAttr ($nodeName + ".deviceAspectRatio") $deviceAspect;
  1824.     }
  1825. }
  1826.  
  1827. global proc checkMayaSoftwareAspectLock(string $nodeName)
  1828. {
  1829.     int $lockOn = `getAttr ($nodeName + ".aspectLock")`;
  1830.  
  1831.     if ($lockOn)
  1832.     {
  1833.         float $h = `getAttr ($nodeName + ".height")`;
  1834.         float $w = `getAttr ($nodeName + ".width")`;
  1835.         float $aspect = $h / $w;
  1836.         setAttr ($nodeName + ".pixelAspect") $aspect;
  1837.     }
  1838.     else
  1839.     {
  1840.         setAttr ($nodeName + ".pixelAspect") 0.0;
  1841.     }
  1842. }
  1843.  
  1844. global proc changeMayaSoftwareAspectLockWidth()
  1845. //
  1846. //  Procedure Name:
  1847. //      changeAspectLockWidth
  1848. //
  1849. //  Description:
  1850. //        This procedure is called when the user changes the
  1851. //        resolution width.  It sets the internal representation
  1852. //        then looks at the ratio lock etc and changes any other 
  1853. //        values that rely on it. 
  1854. //
  1855. {
  1856.     setParentToCommonTab();
  1857.  
  1858.     int $requestedWidth = `intFieldGrp -q -v1 mayaSoftwareResWidth`;
  1859.     int $isMayaEvalVersion = `about -ev`;
  1860.     int $kPLEMaxX = 1024;
  1861.     int $kPLEMaxY =  768;
  1862.     if ($isMayaEvalVersion)
  1863.     {
  1864.         if ($requestedWidth > $kPLEMaxX)
  1865.         {
  1866.             warning("Image resolution is limited to "+$kPLEMaxX+"x"+$kPLEMaxY+" pixels for the Maya Personal Learning Edition");
  1867.             $requestedWidth = $kPLEMaxX;
  1868.         }
  1869.         if (`getAttr defaultResolution.aspectLock`)
  1870.         {
  1871.             float $aspect = `getAttr defaultResolution.pixelAspect`;
  1872.             if ($aspect > 0.0)
  1873.             {
  1874.                 int $rez = $aspect * $requestedWidth;
  1875.                 int $oldrez = `getAttr defaultResolution.height`;
  1876.                 if ($rez <= $kPLEMaxY)
  1877.                 {
  1878.                     if ($rez - $oldrez > 1 || $oldrez - $rez > 1)
  1879.                     {
  1880.                         setAttr defaultResolution.height $rez;
  1881.                     }
  1882.                 }
  1883.                 else
  1884.                 {
  1885.                     intFieldGrp -e -v1 $kPLEMaxY mayaSoftwareResHeight;
  1886.                     changeMayaSoftwareAspectLockHeight;
  1887.                     return;
  1888.                 }
  1889.             }
  1890.         }
  1891.     }
  1892.  
  1893.     if ($requestedWidth < 2)
  1894.     {
  1895.         warning "Width must be at least 2 pixels";
  1896.         $requestedWidth = 2;
  1897.     }
  1898.  
  1899.     setAttr defaultResolution.width $requestedWidth;
  1900.     optionMenuGrp -edit -sl 1 resolutionMenu;
  1901.     checkMayaSoftwareAspectLockWidth "defaultResolution";
  1902.  
  1903.     // Update the values
  1904.     updateMayaSoftwareResolution();
  1905. }
  1906.  
  1907. global proc changeMayaSoftwareAspectLockHeight()
  1908. //
  1909. //  Procedure Name:
  1910. //      changeAspectLockHeight
  1911. //
  1912. //  Description:
  1913. //        This procedure is called when the user changes the
  1914. //        resolution width.  It sets the internal representation
  1915. //        then looks at the ratio lock etc and changes any other 
  1916. //        values that rely on it. 
  1917. //
  1918. {
  1919.     setParentToCommonTab();
  1920.  
  1921.     int $requestedHeight = `intFieldGrp -q -v1 mayaSoftwareResHeight`;
  1922.     int $isMayaEvalVersion = `about -ev`;
  1923.     int $kPLEMaxX = 1024;
  1924.     int $kPLEMaxY =  768;
  1925.     if ($isMayaEvalVersion)
  1926.     {
  1927.         if ($requestedHeight > $kPLEMaxY)
  1928.         {
  1929.             warning("Image resolution is limited to "+$kPLEMaxX+"x"+$kPLEMaxY+" pixels for the Maya Personal Learning Edition");
  1930.             $requestedHeight = $kPLEMaxY;
  1931.         }
  1932.         if (`getAttr defaultResolution.aspectLock`)
  1933.         {
  1934.             float $aspect = `getAttr defaultResolution.pixelAspect`;
  1935.             if ($aspect > 0.0)
  1936.             {
  1937.                 int $rez = $requestedHeight / $aspect;
  1938.                 int $oldrez = `getAttr defaultResolution.width`;
  1939.                 if ($rez <= $kPLEMaxX)
  1940.                 {
  1941.                     if ($rez - $oldrez > 1 || $oldrez - $rez > 1)
  1942.                     {
  1943.                         setAttr defaultResolution.width $rez;
  1944.                     }
  1945.                 }
  1946.                 else
  1947.                 {
  1948.                     intFieldGrp -e -v1 $kPLEMaxX mayaSoftwareResWidth;
  1949.                     changeMayaSoftwareAspectLockWidth;
  1950.                     return;
  1951.                 }
  1952.             }
  1953.         }
  1954.     }
  1955.  
  1956.     if ($requestedHeight < 2)
  1957.     {
  1958.         warning "Height must be at least 2 pixels";
  1959.         $requestedHeight = 2;
  1960.     }
  1961.  
  1962.     setAttr defaultResolution.height $requestedHeight;
  1963.     optionMenuGrp -edit -sl 1 resolutionMenu;
  1964.     checkMayaSoftwareAspectLockHeight "defaultResolution";
  1965.  
  1966.     // Set the proper field ordering if PAL or NTSC.
  1967.     if (`getAttr defaultResolution.height` == 576) // PAL
  1968.     {
  1969.         setAttr "defaultResolution.oddFieldFirst" 0;
  1970.         if (`columnLayout -exists rgFieldLayout`) 
  1971.         {
  1972.             if (`exists updateFieldOptions`)
  1973.             {
  1974.                 updateFieldOptions();
  1975.             }
  1976.         }
  1977.     }
  1978.     else if (`getAttr defaultResolution.height` == 486) // NTSC
  1979.     {
  1980.         setAttr "defaultResolution.oddFieldFirst" 1;
  1981.         if (`columnLayout -exists rgFieldLayout`)
  1982.         {
  1983.             if (`exists updateFieldOptions`)
  1984.             {
  1985.                 updateFieldOptions();
  1986.             }
  1987.         }
  1988.     }
  1989.  
  1990.     // Update the values
  1991.     updateMayaSoftwareResolution();
  1992. }
  1993.  
  1994.  
  1995. global proc adjustMayaSoftwarePixelAspect(string $nodeName)
  1996. {
  1997.     setParentToCommonTab();
  1998.  
  1999.     string $aspectAttr = $nodeName + ".deviceAspectRatio";
  2000.     string $widthAttr = $nodeName + ".width";
  2001.     string $heightAttr = $nodeName + ".height";
  2002.     float  $pixelAspect = (float) `getAttr $widthAttr`
  2003.                           / (float) `getAttr $heightAttr`;
  2004.     $pixelAspect = `getAttr $aspectAttr` / $pixelAspect;
  2005.     floatFieldGrp -e -v1 $pixelAspect pixRatio;
  2006. }
  2007.  
  2008. global proc adjustMayaSoftwareDeviceAspect(string $nodeName)
  2009. {
  2010.     setParentToCommonTab();
  2011.  
  2012.     string $devAspectAttr = $nodeName + ".deviceAspectRatio";
  2013.     string $widthAttr = $nodeName + ".width";
  2014.     string $heightAttr = $nodeName + ".height";
  2015.  
  2016.     float $pixelAspect = `floatFieldGrp -q -v1 pixRatio`;
  2017.     float $aspect = (float) `getAttr $widthAttr`
  2018.                     / (float) `getAttr $heightAttr`;
  2019.     $aspect = $pixelAspect * $aspect;
  2020.     setAttr $devAspectAttr $aspect;
  2021.     floatFieldGrp -edit -v1 $aspect resRatio;
  2022. }
  2023.  
  2024. global proc updateMayaSoftwareDeviceAspectRatio()
  2025. {
  2026.     setParentToCommonTab();
  2027.  
  2028.     setAttr defaultResolution.deviceAspectRatio
  2029.         `floatFieldGrp -q -v1 resRatio`;
  2030.     adjustMayaSoftwarePixelAspect "defaultResolution";
  2031.     updateMayaSoftwareResolution();
  2032. }
  2033.  
  2034. // ----------------------------------------------------------------------------
  2035. // Code to create and update the Render Options frame 
  2036. //
  2037.  
  2038. proc createCommonRenderOptions()
  2039. {
  2040.     string $parent = `setParent -query`;
  2041.  
  2042.     setUITemplate -pushTemplate attributeEditorTemplate;
  2043.  
  2044.     
  2045.     columnLayout -adjustableColumn true;
  2046.     
  2047.         attrControlGrp 
  2048.             -attribute "defaultRenderGlobals.enableDefaultLight";
  2049.         attrControlGrp 
  2050.             -attribute defaultRenderGlobals.pluginFormat 
  2051.             -label "Plug-in Format";
  2052.         attrControlGrp 
  2053.             -attribute defaultRenderGlobals.preRenderMel 
  2054.             -label "Pre Render MEL"
  2055.             preRenderMelSwGrp;
  2056.         attrControlGrp 
  2057.             -attribute defaultRenderGlobals.postRenderMel
  2058.             -label "Post Render MEL"
  2059.             postRenderMelSwGrp;
  2060.  
  2061.         if (`about -evalVersion`)
  2062.         {
  2063.             attrControlGrp -e -enable false preRenderMelSwGrp;
  2064.             attrControlGrp -e -enable false postRenderMelSwGrp;
  2065.         }
  2066.  
  2067.     setParent $parent;
  2068.     setUITemplate -popTemplate;
  2069. }
  2070.  
  2071. //==================================================================
  2072. // Common Tab
  2073. //==================================================================
  2074.  
  2075. global proc updateMayaSoftwareCommonGlobalsTab()
  2076. {
  2077.     //
  2078.     // Description:
  2079.     //    This procedure is called when the current renderer changes to be the
  2080.     //    Maya Software Renderer.
  2081.     //    This procedure updates controls in the Common tab of the Maya Software
  2082.     //    renderer to reflect values which may have been copied from the previous
  2083.     //    current renderer.
  2084.     //
  2085.  
  2086.     updateMayaSoftwareFileNamePrefixControl();
  2087.     updateMayaSoftwareFileNameFormatControl();
  2088.     updateMayaSoftwareImageFormatControl();
  2089.     updateMayaSoftwareUseCustomExtensionControl();
  2090.     updateMayaSoftwareCustomExtensionControl();
  2091.     updateMayaSoftwareCameraControl();
  2092.     updateMayaSoftwareResolution();
  2093. }
  2094.  
  2095. global proc createMayaSoftwareCommonGlobalsTab()
  2096. {
  2097.     //
  2098.     // Description:
  2099.     //    This procedure is called when building the render globals tabs for the
  2100.     //    Maya Software renderer.
  2101.     //    This procedure builds the "General" tab for the Maya Software renderer.
  2102.     //
  2103.  
  2104.     string $renderer = "mayaSoftware";
  2105.  
  2106.     string $parentForm = `setParent -query`;
  2107.  
  2108.         createTargetFilePreview();
  2109.  
  2110.     setParent $parentForm;
  2111.  
  2112.     scrollLayout 
  2113.         -horizontalScrollBarThickness 0 
  2114.         scrollLayout;
  2115.  
  2116.         columnLayout 
  2117.             -adjustableColumn true
  2118.             commonTabColumn;
  2119.  
  2120.             // Image File Name
  2121.             //
  2122.             frameLayout 
  2123.                 -label "Image File Output" 
  2124.                 -collapsable true 
  2125.                 -collapse false
  2126.                 rgImageFileFrame;
  2127.             
  2128.                 createCommonImageFile();
  2129.  
  2130.             setParent commonTabColumn;
  2131.  
  2132.             // Resolution Section
  2133.             //
  2134.             frameLayout 
  2135.                 -label "Resolution" 
  2136.                 -collapsable true 
  2137.                 -collapse false 
  2138.                 rgResolutionFrame;
  2139.  
  2140.                 createCommonResolution(); 
  2141.  
  2142.             setParent commonTabColumn;
  2143.  
  2144.             // Render Options
  2145.             //
  2146.             frameLayout 
  2147.                 -label "Render Options" 
  2148.                 -collapsable true 
  2149.                 -collapse false 
  2150.                 mayaSoftwareOptionFrame;
  2151.  
  2152.                 createCommonRenderOptions(); 
  2153.  
  2154.             setParent commonTabColumn;
  2155.  
  2156.     setParent $parentForm;
  2157.  
  2158.     formLayout
  2159.         -edit 
  2160.         -af targetFilePreview "top" 5
  2161.         -an targetFilePreview "bottom" 
  2162.         -af targetFilePreview "left" 0
  2163.         -af targetFilePreview "right" 0
  2164.         -ac scrollLayout "top" 5 targetFilePreview
  2165.         -af scrollLayout "bottom" 0
  2166.         -af scrollLayout "left" 0
  2167.         -af scrollLayout "right" 0
  2168.         $parentForm;
  2169.  
  2170.     // Update the target file preview. 
  2171.     //
  2172.     updateMayaSoftwareTargetFilePreview;
  2173. }
  2174.  
  2175.